import dayjs from "dayjs";

export const isNull = (date) => {
    if (!date) return true
    const tempTransVal = JSON.stringify(date)
    if (tempTransVal === "{}" || tempTransVal === "[]") return true
}

const filterTimes = (val, format = "YYYY-MM-DD") => {
    // 非空时执行
    if (!isNull(val)) {
        // 值*1000
        val = parseInt(val) * 1000
        return dayjs(val).format(format)
    } else {
        return "--"
    }
}

// 导出为全局函数
export default app => {
    app.config.globalProperties.$filters = {
        filterTimes
    }
}
